<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 没有时则新建
        // const s1 = Symbol.for('foo');

        // // 查找到之前新建的(s1用for时则表示已在全局注册，s2通过字符串描述查找到上s1)
        // const s2 = Symbol.for('foo');

        // console.log('s1',s1);
        // console.log('s2',s2);
        // console.log('s1 === s2', s1 === s2);// true

        // 新建symbol,但未在全局注册，下面s2查找不到则新建了symbol
        const s1 = Symbol('你好');

        const s2 = Symbol.for('你好');
        console.log('s1 === s2', s1 === s2);// false

    </script>
</body>
</html>